﻿using EnvDTE;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
using System.Text;
using Axiom.CodeManifold;
using Axiom.CodeManifold.Framework;

namespace Axiom.CodeManifold.Tests
{
    [TestClass]
    public class BasicTest
    {
		private static Euclid dev;

        [ClassInitialize]
        public static void ClassInitialize(TestContext testContext)
        {
			dev = new Euclid();

			if (dev.IsReady)
			{
				dev.Attach(ReferenceData.SolutionFullName);
			}

			dev.LaunchSolutionInstances();
			
			var t = Task.Run(() =>
			{
				while (!dev.IsReady)
				{
					System.Threading.Thread.Sleep(200);
				}
			});

			Task.WaitAll(new Task[] { t });
		}

        [ClassCleanup]
		public static void CanGetAllCodeModels()
		{
			var models = dev.Ide.AllCodeModels();

			foreach (var item in models)
			{
				System.Diagnostics.Debug.WriteLine(string.Format("Item Name {0}.", item.Parent.Name));
			}

			Assert.IsTrue(models.Count > 0);
        }

		[TestMethod]
		public void CanAutoComment()
		{
			dev.AutoCommentDocument();
		}

		[TestMethod]
		public void CanSortMembers()
		{
			dev.SortMembers();
		}
	}
}